package com.zhifou.handler;

import com.zhifou.common.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author 知否技术
 * @description 全局异常处理器
 * @date 2023-02-23 15:19
 */

@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    public Result handler(Exception e){
        log.error("运行时异常：",e.getMessage());
        return Result.fail(e.getMessage());
    }
}